package com.boot2.core;

import com.boot2.core.dao.SnowflakeGenerator;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * @author zhangweilin
 * @description:主键是Long
 * @date 2018/8/16
 */
@Data
@MappedSuperclass
public class LongBaseEntity extends BaseEntity {
    /**
     * 主键
     */
    @ApiModelProperty(value = "主键id")
    @Id
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom-id")     @GenericGenerator(name = "custom-id", strategy = "com.boot2.core.dao.jpa.IdentifierGeneratorSnowflakeId")
    @GenericGenerator(name="snowflake",strategy = SnowflakeGenerator.TYPE)
    @GeneratedValue(generator = "snowflake")
//	@JsonIgnore // jackson不序列化
//	@JSONField(serialize = false) // fast不序列化
    protected Long id;

    public LongBaseEntity() {
    }

    public LongBaseEntity(boolean isInit) {
        super(isInit);
    }

    @Override
    public Long getId() {
        return id;
    }
}
